using Assets.Scripts;
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using HashTable = ExitGames.Client.Photon.Hashtable;

public class InitCharacterCards : MonoBehaviour
{
    bool selected = false;
    PhotonView _pv;

    public Text playername;
    public Text maxHp;
    public Text speed;
    public Text qi;
    public Text skill;

    CharacterCardsDefine define;
    public void InitInfo(int id)    //从DataManager读取卡牌信息进行初始化
    {
        DataManager.Instance.characterCards.TryGetValue(id, out define);
        playername.text = define.Name;
        maxHp.text = define.MaxHp.ToString();
        speed.text = define.Speed.ToString();
        qi.text = define.Qi.ToString();
        skill.text = define.Skill;

    }

    private void OnMouseDown()  //鼠标点击
    {
        selected = true;
        Highlight(true);
        Debug.Log("点击了一张牌");
        HashTable playerTable = new HashTable();
        playerTable.Add("selected", selected);
        PhotonNetwork.LocalPlayer.SetCustomProperties(playerTable);
    }



    //[PunRPC]
    //void PRC_CardSelect(bool selected, PhotonMessageInfo info)
    //{
        

    //}

    #region 鼠标功能
    private void OnMouseEnter()	//鼠标进入
    {
        Highlight(true);
    }
    private void OnMouseExit()	//鼠标离开
    {
        Highlight(false);
    }
    private void Highlight(bool highlight)  //高亮方法
    {
        if (highlight)
        {
            this.GetComponent<SpriteRenderer>().color = Color.red;
            this.gameObject.transform.Translate(0, 0.5f, 0);
        }
        else
        {
            this.GetComponent<SpriteRenderer>().color = Color.black;
            this.gameObject.transform.Translate(0, -0.5f, 0);
        }

    }
    #endregion

}
